package com.shoping.web.component.other;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ClassUtils;

import java.beans.Introspector;

/**
 * BeanNameGenerator扩展
 */
@Slf4j
@Configuration
public class MyBeanNameGenerator implements BeanNameGenerator {

    @Override
    public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
        String shortClassName = ClassUtils.getShortName(definition.getBeanClassName());
        shortClassName = Introspector.decapitalize(shortClassName);
        log.info("-----0.自定义插件BeanName容器唯一识别Key = {}", shortClassName);
        return shortClassName;
    }
}
